import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  ScrollView,
  Image,
  Animated,
  TouchableOpacity
} from 'react-native';
import styles from './aboutKeeperStyle';

import EasemobChat from '../global/EasemobChat';
import ToastTip from '../global/ToastTip';
import api from '../../services/api';

//本文件未被使用
class VersionIntro extends Component {
    constructor(props) {
		super(props);

		this.state = {
            scrollY: new Animated.Value(0),
            allVersion : []
		};

		// this._getTabHeight = this._getTabHeight.bind(this);
		// this._onChangeTab = this._onChangeTab.bind(this);

		// this.props.navigator.setOnNavigatorEvent(this._onNavigatorEvent.bind(this));
	}

    async componentWillMount() {
        // this._retrieveDetails();
        let res = await api.post('/version/android/list')
        console.log(res)
        if (res.cd==0) {
            this.setState({allVersion:res.data})
        }
	}

    _editPassword(info){
        let {navigator} = this.props;
        navigator.push({
            title: info.version+"版本",
            backButtonTitle:'',
			screen: 'housekeeperapp.versionupdateintro',
			passProps: {
                versionNum:info.id
			},
            navigatorStyle:{
                navBarHidden: false,
                tabBarHidden: true,
                navBarTextColor: 'white',
            	navBarButtonColor: 'white',
            	navBarBackgroundColor: '#EA5404',
                statusBarColor: '#EA5404',
                navBarTitleTextCentered: true,
                topBarElevationShadowEnabled:false
            },
            navigatorButtons: {
                leftButtons:[
                    {
                        id: 'back',
                        icon: require("../../../img/hk_back_icon.png")
                    }
                ]
            }
		});
    }

    render() {
        let { session } = this.props;
        let {allVersion} = this.state;
        if(!session){
            return null;
        }

        let withdraw_password = session.user && session.user.withdraw_password;

        return (
            <View style={styles.container}>
                <ScrollView style={styles.infoList}>
                    {allVersion.map((item,index) => {
                        return (
                            <TouchableOpacity key={index} onPress={this._editPassword.bind(this,item)} style={[styles.addBtn]}>
                                <Text style={[styles.addText,{marginLeft:0}]}>{item.version}版本</Text>
                                <Text style={[styles.rightImage,{color:"#B5B5B5",fontSize:15,marginRight:10}]}></Text>
                                <Image source={require('../../../img/hk_arrow_icon.png')} style={styles.rightImage}/>
                            </TouchableOpacity>                     
                        )
                    })}
                </ScrollView>
            </View>
        );
    }
}

var connectHelper = require('../../services/connectHelper');
VersionIntro = connectHelper(state => state)(VersionIntro);

module.exports = VersionIntro;
